#include<bits/stdc++.h>
using namespace std;
int T,n,m,L,V,a[100010][3],p,maxr,sum;
double cnt(int a,int b,int c)
{
    if(b == 0 || c == 0) return (double)(a);
    return sqrt(a * a + 2 * b * c);
}
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>T;
    while(T--)
    {
        cin>>n>>m>>L>>V;
        maxr = 0;
        sum = 0;
        for(int i = 0;i < n;i++) cin>>a[i][0]>>a[i][1]>>a[i][2];
        for(int i = 0;i < m;i++)
        {
            cin>>p;
            if(p > maxr) maxr = p;
        }
        for(int i = 0;i < n;i++) if(a[i][0] <= maxr && cnt(a[i][1],a[i][2],(maxr - a[i][0])) > (double)(V)) sum++;
        cout<<sum<<' ';
        if(sum == 0) cout<<m<<endl;
        else cout<<(m - 1)<<endl;
    }
    return 0;
}
